<?php
namespace  app\api;

use think\Controller;
class ApiController extends Controller{
	
	
	public function errorParams($msg = ""){
		$msg = empty($msg) ? BAD_PARAM_ERROR : $msg;
		return json(array(
				'code'=>BAD_PARAM_NO,
				'msg'=>$msg,
			)
		);
	}
	/**
	 * 成功输出
	 * @param unknown $data
	 */
	public function successJson($data = []){
		
		return json(array(
						'code'=>SUCCESS_NO,
						'msg'=>SUCCESS_ERROR,
						'data'=>$data
					)
				);
	}
	
	/**
	 * 错误信息输出
	 * @param unknown $msg
	 */
	public function errorMessage($code,$msg=""){
		return json(array(
						'code'=>$code,
						'msg'=>$msg
					)
				);
	}
	
	/**
	 * 自定义输出
	 * @param unknown $code
	 * @param string $msg
	 * @param unknown $data
	 */
	public function customerMessage($msg="",$data=array()){
		$code = CUSTOMER_NO;
		return json(array(
				'code'=>$code,
				'msg'=>empty($msg) ? CUSTOMER_ERROR : $msg,
				'data'=>$data
			)
		);
	}
}